package com.dds.web.controller.app;

import java.util.List;

import com.dds.system.domain.app.AppAdvPosition;
import com.dds.system.service.app.IAppAdvPositionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dds.common.annotation.Log;
import com.dds.common.core.controller.BaseController;
import com.dds.common.core.domain.AjaxResult;
import com.dds.common.enums.BusinessType;
import com.dds.common.utils.poi.ExcelUtil;
import com.dds.common.core.page.TableDataInfo;

/**
 * 广告位置，记录广告的位置信息Controller
 * 
 * @author gaolianjie
 * @date 2021-04-09
 */
@RestController
@RequestMapping("/app/position")
public class AppAdvPositionController extends BaseController
{
    @Autowired
    private IAppAdvPositionService appAdvPositionService;

    /**
     * 查询广告位置，记录广告的位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:position:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppAdvPosition appAdvPosition)
    {
        startPage();
        List<AppAdvPosition> list = appAdvPositionService.selectAppAdvPositionList(appAdvPosition);
        return getDataTable(list);
    }

    /**
     * 导出广告位置，记录广告的位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:position:export')")
    @Log(title = "广告位置，记录广告的位置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppAdvPosition appAdvPosition)
    {
        List<AppAdvPosition> list = appAdvPositionService.selectAppAdvPositionList(appAdvPosition);
        ExcelUtil<AppAdvPosition> util = new ExcelUtil<AppAdvPosition>(AppAdvPosition.class);
        return util.exportExcel(list, "position");
    }

    /**
     * 获取广告位置，记录广告的位置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:position:query')")
    @GetMapping(value = "/{advPositionId}")
    public AjaxResult getInfo(@PathVariable("advPositionId") Long advPositionId)
    {
        return AjaxResult.success(appAdvPositionService.selectAppAdvPositionById(advPositionId));
    }

    /**
     * 新增广告位置，记录广告的位置信息
     */
    @PreAuthorize("@ss.hasPermi('app:position:add')")
    @Log(title = "广告位置，记录广告的位置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppAdvPosition appAdvPosition)
    {
        return toAjax(appAdvPositionService.insertAppAdvPosition(appAdvPosition));
    }

    /**
     * 修改广告位置，记录广告的位置信息
     */
    @PreAuthorize("@ss.hasPermi('app:position:edit')")
    @Log(title = "广告位置，记录广告的位置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppAdvPosition appAdvPosition)
    {
        return toAjax(appAdvPositionService.updateAppAdvPosition(appAdvPosition));
    }

    /**
     * 删除广告位置，记录广告的位置信息
     */
    @PreAuthorize("@ss.hasPermi('app:position:remove')")
    @Log(title = "广告位置，记录广告的位置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{advPositionIds}")
    public AjaxResult remove(@PathVariable Long[] advPositionIds)
    {
        return toAjax(appAdvPositionService.deleteAppAdvPositionByIds(advPositionIds));
    }
}
